<template>
<div>
  <h2>精品推荐</h2>
  <div
    class="shang"
    @click="clickItem(item.id)"
    v-for="item in items"
    :key="item.id">
    <img :src="item.pic" alt />
    <div class="tlite">
      <h3>{{item.name | subStr}}</h3>
      <p class="tlite-p">{{item.characteristic | subStr(20)}}</p>
      <div class="pic">
        <p>
          {{item.minPrice | currency('￥')}}
          <span>{{item.originalPrice | currency('￥')}}</span>
        </p>
        <van-icon name="cart" size="28" color="red" />
      </div>
    </div>
  </div>
</div>
</template>

<script>
import { currency,subStr } from '@/filters'
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickItem (id) {
      this.$emit('clickItem', id)
    },
    // clickAddItem (item) {
    //   // 点击加入购物车按钮
    //   this.$emit('clickAddItem', item)
    // }
  },
  filters: {
    currency,
    subStr
  }
}
</script>

<style lang="scss" scoped>
h2{
  text-align: center;
}
.shang{
  display: flex;
  background: rgb(243,245,247);
  height: 150px;
  margin-top: 7px;
  img{
    width: 150px;
  }
  .tlite{
    flex: 1;
    margin-left: 2px;
    background: #fff;
    padding-right: 10px;
    h3{
      margin:5px 0;
      padding: 0;
    }
    &-p{
      margin-right: 15px;
      color: #666;
    }
    .pic{
      display: flex;
      justify-content: space-between;
      margin-top: 25px;
      padding-right: 5px;
      p{
        margin: 0;
        color: rgb(255, 0, 76);
        span{
          margin-left: 5px;
          font-size: 14px;
          color: #666;
          text-decoration: line-through;
        }
      }
    }
  }
}
</style>